package com.map;

import android.graphics.Point;

import com.facebook.react.bridge.ReadableMap;
import com.facebook.react.uimanager.SimpleViewManager;
import com.facebook.react.uimanager.ThemedReactContext;
import com.facebook.react.uimanager.annotations.ReactProp;

public class RnMapViewManager extends SimpleViewManager<RnMapViewWrapper> {
    public RnMapViewManager() {}

    @Override
    public String getName() {
        return "RnMapViewManager";
    }

    @Override
    protected RnMapViewWrapper createViewInstance(ThemedReactContext reactContext) {
        RnMapViewWrapper mapView = new RnMapViewWrapper(reactContext);
        return mapView;
    }


    // 设置缩放级别
    @ReactProp(name = "zoomLevel")
    public void setZoomLevel(RnMapViewWrapper mapView, float zoomLevel) {
        mapView.setZoomLevel(zoomLevel); //将js端的属性值传递到TubaMapView中完成初始化
    }

    // 设置中心点
    @ReactProp(name = "worldCenter")
    public void setWorldCenter(RnMapViewWrapper mapView, ReadableMap readableMap) {
        int longitude = readableMap.getInt("longitude");
        int latitude = readableMap.getInt("latitude");
        Point worldCenterPoint = new Point(longitude, latitude);
        mapView.setWorldCenter(worldCenterPoint);
    }
}
